<template>
  <div class="theme-demo">
    <el-card class="demo-card">
      <template #header>
        <div class="card-header">
          <h2>主题系统演示</h2>
          <ThemeToggle />
        </div>
      </template>

      <div class="demo-content">
        <el-row :gutter="24">
          <el-col :span="12">
            <div class="demo-section">
              <h3>颜色系统</h3>
              <div class="color-palette">
                <div class="color-item primary">
                  <div class="color-block"></div>
                  <span>主色调</span>
                </div>
                <div class="color-item success">
                  <div class="color-block"></div>
                  <span>成功色</span>
                </div>
                <div class="color-item warning">
                  <div class="color-block"></div>
                  <span>警告色</span>
                </div>
                <div class="color-item danger">
                  <div class="color-block"></div>
                  <span>危险色</span>
                </div>
              </div>
            </div>
          </el-col>

          <el-col :span="12">
            <div class="demo-section">
              <h3>文本颜色</h3>
              <div class="text-samples">
                <p class="text-primary">主要文本颜色</p>
                <p class="text-regular">常规文本颜色</p>
                <p class="text-secondary">次要文本颜色</p>
                <p class="text-placeholder">占位符文本颜色</p>
              </div>
            </div>
          </el-col>
        </el-row>

        <el-row :gutter="24" style="margin-top: 24px;">
          <el-col :span="24">
            <div class="demo-section">
              <h3>组件演示</h3>
              <div class="component-demo">
                <el-button type="primary">主要按钮</el-button>
                <el-button type="success">成功按钮</el-button>
                <el-button type="warning">警告按钮</el-button>
                <el-button type="danger">危险按钮</el-button>
                <el-button type="info">信息按钮</el-button>
              </div>

              <div class="component-demo" style="margin-top: 16px;">
                <el-input placeholder="请输入内容" style="width: 200px; margin-right: 16px;" />
                <el-select placeholder="请选择" style="width: 200px;">
                  <el-option label="选项1" value="1" />
                  <el-option label="选项2" value="2" />
                </el-select>
              </div>
            </div>
          </el-col>
        </el-row>

        <el-row :gutter="24" style="margin-top: 24px;">
          <el-col :span="24">
            <div class="demo-section">
              <h3>卡片和表格</h3>
              <el-table :data="tableData" style="width: 100%">
                <el-table-column prop="name" label="姓名" />
                <el-table-column prop="role" label="角色" />
                <el-table-column prop="status" label="状态">
                  <template #default="{ row }">
                    <el-tag :type="row.status === '在线' ? 'success' : 'info'">
                      {{ row.status }}
                    </el-tag>
                  </template>
                </el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-row>
      </div>
    </el-card>
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import ThemeToggle from '@/components/ThemeToggle.vue'

const tableData = ref([
  { name: '张三', role: '学生', status: '在线' },
  { name: '李四', role: '老师', status: '离线' },
  { name: '王五', role: '管理员', status: '在线' }
])
</script>

<style lang="scss" scoped>
.theme-demo {
  padding: 24px;
  background: var(--bg-color-page);
  min-height: calc(100vh - 60px);
  transition: background-color 0.3s ease;
}

.demo-card {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  box-shadow: var(--box-shadow-light);
  transition: all 0.3s ease;

  &:hover {
    box-shadow: var(--box-shadow);
  }

  :deep(.el-card__header) {
    background: var(--bg-color-overlay);
    border-bottom: 1px solid var(--border-color);
  }

  :deep(.el-card__body) {
    background: var(--bg-color);
  }
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;

  h2 {
    color: var(--text-color-primary);
    margin: 0;
    font-weight: 600;
  }
}

.demo-section {
  margin-bottom: 24px;

  h3 {
    color: var(--text-color-primary);
    margin-bottom: 16px;
    font-weight: 600;
  }
}

.color-palette {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;

  .color-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;

    .color-block {
      width: 60px;
      height: 60px;
      border-radius: 8px;
      border: 1px solid var(--border-color);
      transition: all 0.3s ease;

      &:hover {
        transform: translateY(-2px);
        box-shadow: var(--box-shadow);
      }
    }

    span {
      color: var(--text-color-secondary);
      font-size: 12px;
    }

    &.primary .color-block {
      background: var(--color-primary);
    }

    &.success .color-block {
      background: var(--color-success);
    }

    &.warning .color-block {
      background: var(--color-warning);
    }

    &.danger .color-block {
      background: var(--color-danger);
    }
  }
}

.text-samples {
  .text-primary {
    color: var(--text-color-primary);
    margin: 8px 0;
  }

  .text-regular {
    color: var(--text-color-regular);
    margin: 8px 0;
  }

  .text-secondary {
    color: var(--text-color-secondary);
    margin: 8px 0;
  }

  .text-placeholder {
    color: var(--text-color-placeholder);
    margin: 8px 0;
  }
}

.component-demo {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;

  .el-button {
    transition: all 0.3s ease;

    &:hover {
      transform: translateY(-1px);
    }
  }
}

// 表格样式优化
:deep(.el-table) {
  background: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;

  .el-table__header {
    background: var(--bg-color-overlay);

    th {
      background: var(--bg-color-overlay);
      color: var(--text-color-primary);
      border-bottom: 1px solid var(--border-color);
    }
  }

  .el-table__body {
    tr {
      background: var(--bg-color);

      &:hover {
        background: var(--bg-color-overlay);
      }

      td {
        border-bottom: 1px solid var(--border-color-light);
        color: var(--text-color-primary);
      }
    }
  }
}

// 输入框和选择器样式优化
:deep(.el-input__wrapper) {
  background: var(--bg-color-overlay);
  border-color: var(--border-color);
  transition: all 0.3s ease;

  &:hover {
    border-color: var(--border-color-hover);
  }

  &.is-focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.2);
  }
}

:deep(.el-input__inner) {
  color: var(--text-color-primary);

  &::placeholder {
    color: var(--text-color-placeholder);
  }
}

:deep(.el-select) {
  .el-input__wrapper {
    background: var(--bg-color-overlay);
  }
}
</style>
